package com.kaifamiao.demo.d0907;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBUtilTest {

    public static void main(String[] args) {
        try(DBUtil db = new DBUtil("jdbc:mysql://localhost:3306/kfm", "root", "");){
            int update = db.update("update users set password = ? where id = ?", "a123456", 1);

            System.out.println(update);

        } catch (SQLException e) {
            e.printStackTrace();
        }





        //        try {
//            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mis", "root", "");
//
//            ResultSet set = db.query(connection, "select * from employee");
//
//            while (set.next()){
//                System.out.println(set.getObject(1));
//            }
//
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }


//        try {
//            ResultSet set = db.query("select * from users");
//
//            while (set.next()){
//                System.out.println(set.getObject(1));
//            }
//
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
//
//        try {
//            ResultSet set = db.query("select * from users where id = ?", 1);
//            while (set.next()){
//                System.out.println(set.getObject(2));
//            }
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
    }
}
